
// 左下统计1

const StatisticalList = {
    template: '#statisticalList',
    props: ['currenType', 'cityName'],
    data() {
        return {
            statistical: [],
            warningInfo: {
                warningLv: {
                    low: '低风险',
                    major: '重大风险',
                    larger: '较大风险',
                    general: '一般风险'
                },
                warningType: 'low',//等级
                heightArea: ['南京市', '常州市', '无锡'],
                list: []
            }
        }
    },
    computed: {
        currentLv() {
            return this.warningInfo.warningLv[this.warningInfo.warningType]
        }

    },
    mounted() {
        this.init()
    },

    methods: {
        init() {
            this.setValue()
            this.setWaringValue()
        },
        setValue() {
            service.get('/mock.json', {
                params: {
                    // 参数类型
                    type: this.currenType,
                    cityName: this.cityName
                }
            }).then((res) => {
                // let { data } = res
                this.statistical = [{
                    name: '重大危险源企业',
                    icon: 'b-icon1.png',
                    value: [
                        {
                            name: '一级',
                            value: Math.floor(Math.random() * 100)
                        }, {
                            name: '二级',
                            value: Math.floor(Math.random() * 100)
                        }
                    ]
                }, {
                    name: '重大危险源',
                    icon: 'b-icon2.png',
                    value: [
                        {
                            name: '一级',
                            value: Math.floor(Math.random() * 100)
                        }, {
                            name: '二级',
                            value: Math.floor(Math.random() * 100)
                        }
                    ]
                }, {
                    name: '接入设备',
                    icon: 'b-icon3.png',
                    value: [
                        {
                            name: '一级',
                            value: Math.floor(Math.random() * 100)
                        }, {
                            name: '二级',
                            value: Math.floor(Math.random() * 100)
                        }
                    ]
                }]
            })
        },
        setWaringValue() {
            service.get('/mock.json', {
                params: {
                    // 参数类型
                    type: this.currenType,
                    cityName: this.cityName
                }
            }).then((res) => {
                // let { data } = res
                this.warningInfo.warningType = "low"

                this.warningInfo.heightArea = ['南京市', '常州市', '无锡']
                this.warningInfo.list = [{
                    name: '重大风险',
                    value: Math.floor(Math.random() * 100)
                }, {
                    name: '较大风险',
                    value: Math.floor(Math.random() * 100)
                }, {
                    name: '一般风险',
                    value: Math.floor(Math.random() * 100)
                }, {
                    name: '低风险',
                    value: Math.floor(Math.random() * 100)
                }]

            })
        }
    },
    watch: {
        currenType(newValue, oldValue) {
            // 类型改变后一系列动作
            this.init()
        },
        cityName(newValue, oldValue) {
            // 城市改变后一系列动作
            this.init()
        }
    }
}